﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CodeCamp12.Domain;
using CodeCamp12.DAL;
using log4net;

namespace CodeCamp12.BLL
{
    public class TrackBL
    {
        private ILog log = LogManager.GetLogger("CodeCamp12.BLL");

        /// <summary>
        /// Inserts new track for some event
        /// </summary>
        /// <param name="track"></param>
        public void InsertTrack(Track track)
        {
            var trackDataProvider = new TrackDataManagement();
            
            try
            {
                trackDataProvider.InsertTrack(track);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }

        /// <summary>
        /// Deletes track from the web site
        /// </summary>
        /// <param name="track"></param>
        public void DeleteTrack(Track track)
        {
            var trackDataProvider = new TrackDataManagement();

            try
            {
                trackDataProvider.DeleteTrack(track);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }

        /// <summary>
        /// Returns all track for event with id passed in parametars
        /// </summary>
        /// <param name="eventId"></param>
        /// <returns></returns>
        public List<Track> GetAllTracks(Guid eventId)
        {
            var trackDataProvider = new TrackDataManagement();
            try
            {
                return trackDataProvider.GetAllTracks(eventId);
            }
            catch (Exception ex)
            {
                log.Error(ex); 
                throw;
            }

        }
    }
}
